package com.dinim.object;

import com.dinim.matrix.twodimensional.IPoint2D;

public class Rectangle2D extends Object2D{

    public Rectangle2D(double x, double y, double width, double height) {        
        super(createPoints(x, y, width, height), createConnections());
    }

    public Rectangle2D(IPoint2D[] points, int[] connections) {
        super(points, connections);
    }

    public static int[] createConnections(){
        return new int[]{0,1,2,3};
    }
    
    public static IPoint2D[] createPoints(double x, double y, double width, double height){
        Point2D p1 = new Point2D(x, y);
        Point2D p2 = new Point2D(x + width, y);
        Point2D p3 = new Point2D(x + width, y + height);
        Point2D p4 = new Point2D(x, y + height);
        
        IPoint2D[] points = new Point2D[]{p1, p2, p3, p4};
        return points;
    }
    
}
